package com.zhongxi.guoyuan.OffLineShop.UI;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.zhongxi.guoyuan.R;

import io.reactivex.disposables.Disposable;

/**
 * Created by Administrator on 2018/1/18.
 */

public class OffLineBaseActivity extends AppCompatActivity {

    protected Disposable mDisposable;
    protected int page = 1;
    private ProgressDialog mProgressDialog;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        initActionBar();
        initView();
        initNetWork();
        initListener();
    }

    protected void init() {

    }

    protected void initActionBar() {

    }

    protected void initView() {

    }

    protected void initNetWork() {

    }

    protected void initListener() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unsubscribe();
    }

    protected void unsubscribe() {
        if (mDisposable != null && !mDisposable.isDisposed()) {
            mDisposable.dispose();
        }
    }

    protected void showProgressDialog() {
        if (mProgressDialog == null) {
            mProgressDialog = new ProgressDialog(this, R.style.CustomProgressDialog);
        }
        mProgressDialog.setMessage("加载中....");
        mProgressDialog.setIndeterminateDrawable(getResources().getDrawable(R.drawable.progressbarstyle_large));
        mProgressDialog.show();
    }

    protected void dismessProgressDialog() {
        if (mProgressDialog != null && mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
    }

}
